﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL.Translator
{
    /// <summary>
    /// Define User Translator
    /// </summary>
   public class UserTranslator
    {
       /// <summary>
       /// To Translate View_UserInfoBusinessEntity to View_UserInfoDataEntity
       /// </summary>
       /// <param name="user"></param>
       /// <returns></returns>
        public static DAL.View_UserInfo TranslateBusinessToEntityView(BLL.User user)
        {
            DAL.View_UserInfo User = new DAL.View_UserInfo();
            User.UserId = user.UserId;
            User.FirstName = user.FirstName;
            User.LastName = user.LastName;
            user.Department = new BLL.Department();
            user.Role = new BLL.Role();
            User.DepartmentName = user.Department.DepartmentName;
            User.DepartmentId = user.Department.DepartmentId;
            User.RoleId = user.Role.RoleId;
            User.RoleName = user.Role.RoleName;
            return User;
        }

       /// <summary>
       /// To Translate View_UserInfoDataEntity to View_UserInfoBusinessEntity
       /// </summary>
       /// <param name="user"></param>
       /// <returns></returns>
        public static BLL.User TranslateEntityViewToBusiness(DAL.View_UserInfo user)
        {
            BLL.User User = new BLL.User();
            User.UserId = user.UserId;
            User.FirstName = user.FirstName;
            User.LastName = user.LastName;
            User.Department = new BLL.Department();
            User.Role = new BLL.Role();
            User.Department.DepartmentName = user.DepartmentName;
            User.Department.DepartmentId = user.DepartmentId;
            User.Role.RoleName = user.RoleName;
            User.Role.RoleId = user.RoleId;
            return User;
        }

       /// <summary>
       /// To Translate UserBusinessEntity to UserDataEntity
       /// </summary>
       /// <param name="user"></param>
       /// <returns></returns>
        public static DAL.User TranslateBusinessToEntity(BLL.User user)
        {
            DAL.User User = new DAL.User();
            User.UserId = user.UserId;
            User.FirstName = user.FirstName;
            User.LastName = user.LastName;
            User.DepartmentId = user.Department.DepartmentId;
            User.RoleId = user.Role.RoleId;
            
            return User;
        }

       /// <summary>
       /// To Translate UserDataEntity to UserBusinessEntity
       /// </summary>
       /// <param name="user"></param>
       /// <returns></returns>
        public static BLL.User TranslateEntityToBusiness(DAL.User user)
        {
            BLL.User User = new BLL.User();
            User.UserId = user.UserId;
            User.FirstName = user.FirstName;
            User.LastName = user.LastName;
            User.Department = new BLL.Department();
            User.Department.DepartmentId = user.DepartmentId;
            User.Department.DepartmentName = user.Department.DepartmentName;
            User.Role = new BLL.Role();
            User.Role.RoleId = user.RoleId;
            User.Role.RoleName = user.Role.RoleName;
            
            return User;
        }

    }
}
